<template>
  <component :is="showComponent" />
  <button @click="tabComponent">切换A/B组件</button>
</template>

<script setup lang="ts">
import A from './A.vue';
import B from './B.vue';
import { shallowRef } from 'vue';
let showComponent = shallowRef<any>(A);
const tabComponent = (): void => {
  if (showComponent.value === A) {
    showComponent.value = B;
  } else {
    showComponent.value = A;
  }
};
</script>
